package com.itheima.demo1.test;

import com.itheima.demo1.domain.Student;

import java.util.ArrayList;
import java.util.Scanner;

public class StudentSystem {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        ArrayList<Student> list = new ArrayList<>();

        lo:
        while (true){
            System.out.println("--------欢迎来到学生管理系统--------");
            System.out.println("1 添加学生");
            System.out.println("2 删除学生");
            System.out.println("3 修改学生");
            System.out.println("4 查看学生");
            System.out.println("5 退出");
            System.out.println("请输入您的选择:");

            String choice = sc.next();

            switch (choice){
                case "1":
                    System.out.println("添加学生");
                    addStudent(list);
                    break ;
                case "2":
                    System.out.println("删除学生");
                    break ;
                case "3":
                    System.out.println("修改学生");
                    break ;
                case "4":
                    queryStudent(list);
                    break ;
                case "5":
                    System.out.println("感谢您的使用");
                    break lo;
                default:
                    System.out.println("您的输入有误，请重新输入");
            }

        }
    }

    public static void queryStudent(ArrayList<Student> list) {
        if(list.size() == 0){
            System.out.println("没有数据");
        }else{
            System.out.println("学号\t姓名\t年龄\t生日");
            for (int i = 0; i < list.size(); i++) {
                Student stu = list.get(i);
                System.out.println(stu.getCode()+"\t"+stu.getName()+"\t"+stu.getAge()+"\t"+stu.getBirthday());
            }
        }
    }

    public static void addStudent(ArrayList<Student> list) {
        Scanner sc = new Scanner(System.in);
        System.out.println("学号");
        String code = sc.next();
        System.out.println("姓名");
        String name = sc.next();
        System.out.println("年龄");
        int age = sc.nextInt();
        System.out.println("生日");
        String birthday = sc.next();
        Student stu = new Student(code,name,age,birthday);
        list.add(stu);
        System.out.println("添加成功1");
        System.out.println("添加成功2");
        System.out.println("添加成功3");
    }
}
